#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 crane <crane@his-pc>
#
# Distributed under terms of the MIT license.

"""

"""

class Solution:
    """
    @param numbers: An array of Integer
    @param target: target = numbers[index1] + numbers[index2]
    @return: [index1, index2] (index1 < index2)
    """
    def twoSum(self, numbers, target):
        d = {}
        for i, n in enumerate(numbers):
            # d[n] = i                            # 不要先设置d[n] = i,
            another = target - n
            # if another == n: continue           # numbers中有可能有重复(8 = 4 + 4, 6 = 3 + 3, 并且重复元素)
            if another in d:
                # return d[n], d[target-n]
                return d[another], i
            d[n] = i                              # 后设置d[n] = i, 如果是两个相同的数, if 判断时不会寻找到自身(先设置则会if 判真)


def main():
    print("start main")

if __name__ == "__main__":
    main()
